<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>js集合Map之遍历</title>
</head>
<body>
  <ul>
    <li>可使用keys()获取Map的键,values()获取Map的值，使用entries()获取键值对</li>
    <li>可使用forEach或for...of来遍历Map，注意forEach的参数(val,key)</li>
  </ul>
  <script>
    const map = new Map([['name', 'miracle'], ['age', 35]])
    console.log(map.keys())    // MapIterator {"name", "age"}
    console.log(map.values())  // MapIterator {"miracle", 35}
    console.log(map.entries()) // MapIterator {"name" => "miracle", "age" => 35}
    map.forEach((val, key) => console.log(key, val))
    for (const [key, val] of map) {
      console.log(key, val)
    }
  </script>
</body>
</html>